package net.htjs.jdkgrammer.jdk19;

import java.util.concurrent.TimeUnit;

public class OfVirtualTest {

    public static void main(String[] args) throws InterruptedException {
        //创建任务
        Runnable task = () -> {
            System.out.println(Thread.currentThread().getName());
        };

        //创建虚拟线程命名为虚拟线程，将任务task传入
        Thread vt1 = Thread.ofVirtual().name("虚拟线程").unstarted(task);
        vt1.start();//启动虚拟线程

        //主线程睡眠，否则可能看不到控制台的打印
        TimeUnit.SECONDS.sleep(1);

    }
}
